# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=joomlavs
pkgver=254.eea7500
pkgrel=13
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner' 'blackarch-fuzzer')
pkgdesc='A black box, Ruby powered, Joomla vulnerability scanner.'
arch=('any')
url='https://github.com/rastating/joomlavs'
license=('GPL3')
depends=('ruby' 'ruby-bundler' 'libxslt')
makedepends=('git')
source=("git+https://github.com/rastating/$pkgname.git"
        'gemfile.patch')
install="$pkgname.install"
sha512sums=('SKIP'
            'c5a47c38ca04a1bafa83f412db6cef594bee8b0ee3033632aaf9de6114d8d7f0fae42a81da477bc41b81f43fb3ff420cce6793800fad9d278119dfa19b50a0c6')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare(){
  patch -p1 < gemfile.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
bundle exec ./$pkgname.rb "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

